<?php

namespace App\Http\Requests\customer;

use App\Http\ValidateResult;
use Illuminate\Support\Facades\Validator;

trait NodeRequest
{
    public static function add_check(array $params): ValidateResult {
        $validator = Validator::make($params, [
            'customer_id' => 'required',
            'name_cn' => 'required',
            'name_en' => 'required',
            'api_id' => 'required'
        ], [
            'customer_id.required' => '请选择大客户',
            'name_cn.required' => '请填写中文名称',
            'name_en.required' => '请填写英文名称',
            'api_id.required' => '请选择对应接口',
        ]);

        if ($validator->fails()) {
            return ValidateResult::error($validator->errors()->first());
        }
        return ValidateResult::correct();
    }

}
